package com.icangya.DAO.impl;

import com.icangya.DAO.IPayInfoDAO;
import com.icangya.domain.FbPayInfo;
import com.icangya.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;

@Repository
public class PayInfoDAOImpl extends  BaseDAO<FbPayInfo> implements IPayInfoDAO {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public FbPayInfo getPayInfoByMchTradeId(String mchTradeId) {

        String hql=" FROM FbPayInfo pi WHERE pi.mch_trade_id = ? ";

        List<FbPayInfo> list = (List<FbPayInfo>) getHibernateTemplate().find(hql, mchTradeId);
        if (list != null && list.size() > 0){
            return list.get(0);
        }

        return null;
    }

    @Override
    public List<FbPayInfo> getFbPayInfoListByDate(Timestamp payDate) {

        String hql=" FROM FbPayInfo rr WHERE TO_DAYS(rr.payDate) = TO_DAYS(?) ";

        List<FbPayInfo> list = (List<FbPayInfo>) getHibernateTemplate().find(hql, payDate);
        if (list != null && list.size() > 0){
            return list;
        }

        return null;

    }


}
